package com.itheima.filters;

import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @Author：shenkunlin
 * @date： 2021/7/12 16:24
 * @Description：局部过滤器
 ***/
@Component
public class OrderRespGatewayFilterFactory extends AbstractGatewayFilterFactory {

    /**
     * 拦截
     * @param config
     * @return
     */
    @Override
    public GatewayFilter apply(Object config) {
        return new GatewayFilter() {
            @Override
            public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
                System.out.println("hello!这里是局部过滤器，不是全局的！");
                return chain.filter(exchange);
            }
        };
    }
}
